import React, { Component, Suspense } from 'react';
import { connect } from 'dva';
import { Layout, Menu, Breadcrumb, Carousel, Row, Col, Icon, Button, Divider, Tabs} from 'antd';
// import Ellipsis from '@/components/Ellipsis';
// import Slider from '@/components/Slider'
// import ActivitySlider from '@/components/ActivitySlider'
// import BigTitle from '@/components/BigTitle'
// import AboutUS from '@/components/AboutUS'
// import Question from '@/components/Question'
import InformationList from '@/components/InformationList'
// import {BIAOTI, GYWM, JIANTOU4, YUAN} from '../../constants'
// import styles from './index.less';
// import router from 'umi/router';

@connect(({ chart, loading }) => ({
  // chart,
  // loading: loading.effects['chart/fetch'],
}))
class Information extends Component {
  state = {
  };

  componentDidMount() {
  }

  componentWillUnmount() {
  }

  getJsx = (data) => {
    const jsx = data.map((item, key) => (
      <Col span={6} key={key}>
        <InformationList data={item}  />
      </Col>
    ));
    let newJsx = [];
    for (let i in jsx) {
      if (parseInt(i) !== jsx.length -1) {
        // newJsx.push(jsx[i], <Divider type="vertical" style={{height: 80, margin: '34px 70px'}} />);
        newJsx.push(jsx[i], (
          <Col span={1} style={{textAlign: 'center'}} key={jsx.length+parseInt(i)}>
            <Divider type="vertical" style={{height: 80, margin: '90px auto'}} />
          </Col>
        ));
      }
      else {
        newJsx.push(jsx[i]);
      }
    }
    return newJsx
  }

  group =(array, subGroupLength)=>{
    let index = 0;
    let newArray = [];
    while(index < array.length) {
      newArray.push(array.slice(index, index += subGroupLength));
    }
    return newArray;
  }

  render() {
    const {informationList} = this.props
    let data = [];
    if (informationList.length>9){
      data = this.group(informationList.slice(0,9), 3);
      // console.log("information",data)
    }else {
      data = this.group(informationList, 3);;
    }

    return (
      <Row type='flex' justify='center'>
        {this.getJsx(data)}
      </Row>
    );
  }
}

export default Information;
